using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Backend.JYD.AModel.Models.Mapping
{
    public class EmpAuthInfoMap : EntityTypeConfiguration<EmpAuthInfo>
    {
        public EmpAuthInfoMap()
        {
            // Primary Key
            this.HasKey(t => new { t.EmpId, t.AuthId, t.CreateTime, t.UpdateTime });

            // Properties
            this.Property(t => t.EmpId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.AuthId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("EmpAuthInfo");
            this.Property(t => t.EmpId).HasColumnName("EmpId");
            this.Property(t => t.AuthId).HasColumnName("AuthId");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
            this.Property(t => t.UpdateTime).HasColumnName("UpdateTime");
            this.Property(t => t.OpId).HasColumnName("OpId");

            // Relationships
            this.HasRequired(t => t.AuthorityInfo)
                .WithMany(t => t.EmpAuthInfoes)
                .HasForeignKey(d => d.AuthId);
            this.HasRequired(t => t.EmpInfo)
                .WithMany(t => t.EmpAuthInfoes)
                .HasForeignKey(d => d.EmpId);

        }
    }
}
